import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

/**
 * 主函数
 */
public class main {
    private static Scanner scanner=new Scanner(System.in);

    public static void main(String[] args) {
        User user=login();
        BookList bookList=new BookList();
        while (true){
            int choice = user.menu();
            if(choice==-1){
                continue;
            }
            if(choice==0){
                System.out.println("再见！");
                break;
            }
            user.DoOperation(choice,bookList);
        }

    }

    private static User login() {
        System.out.println("请输入用户名：");
        String name=scanner.next();
        System.out.println("请选择您的角色，1表示普通用户，2表示管理员");
        int choice= scanner.nextInt();
        if(choice==1){
            return new NormalUser(name);
        }else if(choice==2){
            return new AdminUser(name);
        }else {
            System.out.println("你的输入有误，请重新输入！");
            return login();
        }
    }
}
